//单独验证某一个input  class="checkpass"
$(function() {
	$("#form").validate({
		submitHandler : function(form) {// 必须写在验证前面，否则无法ajax提交
			var key=$("#form").find("button");
			key.attr("disabled","disabled");
			ly.ajaxSubmit(form, {// 验证新增是否成功
				type : "post",
				dataType : "json",
				success : function(data) {	
					if (data == "success") {
						layer.closeAll();
						_DataTable.ajax.reload(CallBack(), false);
						layer.msg('保存成功', {icon: 1});
					} else {
						layer.alert('添加失败！' + '--------'+data, 3);
					}
				}
			});
		},
		rules : {
			"datauserFormMap.password" : {
				required : true,
				rangelength:[8,30],
			},
			"datauserFormMap.username" : {
				required : true,
				rangelength:[5,30],
			},
			"datauserFormMap.cellphone" : {
				required : true,
			},
			"datauserFormMap.enterprise" : {
				required : true,
				rangelength:[5,255],
			},
			"datacenterFormMap.address" : {
				required : false,
				rangelength:[5,255],
			},
			"datasourceFormMap.en_qq" : {
				required : false,
				rangelength:[5,255],
			},
			"datasourceFormMap.en_weixin" : {
				required : false,
				rangelength:[5,255],
			},
			"datasourceFormMap.en_url" : {
				required : false,
				rangelength:[5,255],
			},
		},
		messages : {
			"datauserFormMap.cellphone" : {
				required : "手机号码不能为空",
				remote : "手机号码已经存在",
				
			},
			"datauserFormMap.password" : {
				required : "输入密码不能为空",
				required:"输入值必须介于8,30"
			},
			"datauserFormMap.username" : {
				required : "输入用户名不能为空",
				required:"输入值必须介于5,30"
			},
			"datauserFormMap.enterprise" : {
				required : "输入企业名称不能为空",
				required:"输入值必须介于5,255"
			},
			"datacenterFormMap.address" : {
				required : "输入企业名称不能为空",
				required:"输入值必须介于5,255"
			},
			"datasourceFormMap.en_qq" : {
				required : "输入企业qq不能为空",
				required:"输入值必须介于0,255"
			},
			"datasourceFormMap.en_weixin" : {
				required : "输入企业weixin不能为空",
				required:"输入值必须介于0,255"
			},
			"datasourceFormMap.en_url" : {
				required : "输入企业url不能为空",
				required:"输入值必须介于0,255"
			},
//			"datauserFormMap.inputseq" : {
//				required : "输入顺序不能为空",
//			},
//			"datauserFormMap.promptContent" : {
//				required : "提示信息不能为空",
//			},
		},
		errorPlacement : function(error, element) {// 自定义提示错误位置
			$(".l_err").css('display', 'block');
			// element.css('border','3px solid #FFCCCC');
			$(".l_err").html(error.html());
		},
		success : function(label) {// 验证通过后
			$(".l_err").css('display', 'none');
		}

	});
	
});

